﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LianjiUI : MonoBehaviour
{

    public Image[] numimages;

    //public int number;

    int startnum = 0;
    int endnum = 1;

    private void Start()
    {
      //  Init(number);
    }
    //235
    public void Init(int num)
    {
        startnum = 0;
        endnum = 1;
        
        for (int i =0 ; i < numimages.Length; i++)
        {
            if (num.ToString().Length <=i)
            {
                numimages[i].gameObject.SetActive(false);
            }
        }
        //string ss = num.ToString().Substring(1,1);
        //Debug.Log("==-==" + ss);
        for (int i = 0; i < num.ToString().Length; i++)
        {
            string ss = num.ToString().Substring(startnum, endnum);
            //Debug.Log("==-==" + ss);
            numimages[i].sprite = Resources.Load<Sprite>(GetNumPath(ss));
            startnum++;
            //endnum++;

        }
    }

    private string GetNumPath(string name)
    {
        string ss = "";
        switch (name)
        {
            case "0":
               ss = VariableDocument.GetInstance.numpath[0];
                break;
            case "1":
                ss = VariableDocument.GetInstance.numpath[1];
                break;
            case "2":
                ss = VariableDocument.GetInstance.numpath[2];
                break;
            case "3":
                ss = VariableDocument.GetInstance.numpath[3];
                break;
            case "4":
                ss = VariableDocument.GetInstance.numpath[4];
                break;
            case "5":
                ss = VariableDocument.GetInstance.numpath[5];
                break;
            case "6":
                ss = VariableDocument.GetInstance.numpath[6];
                break;
            case "7":
                ss = VariableDocument.GetInstance.numpath[7];
                break;
            case "8":
                ss = VariableDocument.GetInstance.numpath[8];
                break;
            case "9":
                ss = VariableDocument.GetInstance.numpath[9];
                break;
        }
        return ss;
    }

    public void LjHandle()
    {
        Destroy(this.gameObject);
    }
}
